package com.kele.service.Interceptor;

import com.kele.domain.User;
import com.kele.utils.newUser;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 创作人 王箫凯
 * Date 2021/6/7
 * Time 14:36
 * 此拦截器的作用是对用户登陆后个人信息是否为空进行拦截，如果为空，则表示用户可能为初次登录，要求其进行个人信息的玩啥
 * @author 王箫凯
 */
public class UserInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//        boolean flag=true;
//        //获取session
//        if (request.getSession().getAttribute("User")!=null){
//            User user= (User) request.getSession().getAttribute("User");
//            System.out.println(user);
//            newUser newUser=new newUser();
//            flag=newUser.isNewUser(user);
//            System.out.println(flag);
//            if (!flag){
//                //表示该用户的信息为存在空
//                response.sendRedirect(request.getContextPath()+"/to/toPerfect");
//                return false;
//            }
//        }


        //设置布尔类型进行判断 判断用户的基本信息是否填写

        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {

    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {

    }
}
